<?php
/**
 * Main application config
 *
 * @category  Yii Template
 * @author    Dmitry Konovalchuk <konovalchuk@ebola.com.ua>
 * @copyright 2013 Ebola Communications
 * @link      http://www.ebola.com.ua/
 */
$dir        = dirname(__FILE__);
$protected  = realpath($dir . '/..');
$envFile    = realpath($dir . '/environments/' . ENVIRONMENT . '.php');
$env        = is_file($envFile) ? require($envFile) : array();
$localFile  = realpath($dir . '/local.php');
$local      = is_file($envFile) ? require($localFile) : array();
$cmsFile    = realpath($dir . '/main_cms.php');
$cms        = (USE_YIIHOO_CMS && is_file($cmsFile)) ? require($cmsFile) : array();
$paramsFile = realpath($dir . '/params.php');
$params     = is_file($paramsFile) ? require($paramsFile) : array();

$config = array(
    'name'           => 'Yii Template',
    'basePath'       => $protected,
    'language'       => 'ru',
    'sourceLanguage' => 'en',

    'aliases' => array(
        'xupload'     => 'application.vendor.xupload',
        'csvexporter' => 'ext.csvexporter',
    ),

    'import' => array(
        'application.components.*',
        'application.models.*',
        'application.widgets.*',
        'csvexporter.components.*',
        'csvexporter.widgets.ReportButtons',

        'application.modules.userActivity.components.*',
        'application.modules.userActivity.models.*',
    ),

    'components' => array(
        'csvexporter' => array(
            'class' => 'CsvExporter',
        ),

        'bootstrap' => array(
            'class' => 'Bootstrap',
        ),
        'bootstrap2' => array(
            'class' => 'Bootstrap2',
        ),
        'assetManager' => array(
            'linkAssets' => true,
        ),
        'db' => array(
            'charset'        => 'utf8',
            'emulatePrepare' => true,
        ),
        'log' => array(
            'class'  => 'CLogRouter',
            'routes' => array(
                array(
                    'class'  => 'CFileLogRoute',
                    'levels' => 'error, warning',
                ),
            ),
        ),
        'request' => array(
            'enableCookieValidation' => true,
            'enableCsrfValidation'   => true,
        ),
        'urlManager' => array(
            'urlFormat'      => 'path',
            'showScriptName' => false,
            'rules'          => array(
            ),
        ),
    ),

    'modules' => array(
        'userActivity' => array(
        ),
    ),

    'params' => $params,
);

return CMap::mergeArray(
    CMap::mergeArray(
        CMap::mergeArray($config, $cms),
        $env
    ),
    $local
);
